// index.js
import {
  get,
  post
} from '../../utils/request'
import {
  APIS
} from '../../utils/api'
import { timestampToTime } from '../../utils/util'
// 获取应用实例
const app = getApp()

Page({
  data: {
    shopInfo: {},
    operating: {},
    search: '',
    orders: []
  },
  onLoad() {
    const shopInfo = wx.getStorageSync('currShop');
    this.setData({
      shopInfo
    }, () => {
      this.getInfo()
    });
  },
  onShow() {
    
  },
  handleChangeShop(e) {
    const currShop = e.detail;
    this.setData({
      shopInfo: currShop
    });
  },
  handleInput(e) {
    let value = e.detail.value;
    this.setData({
      search: value
    })
  },
  handleJump() {
    wx.navigateTo({
      url: '/pages/storemanage/index'
    })
  },
  getInfo() {
    get(`${APIS.statistics}/shop/${this.data.shopInfo.id}`)
      .then(res => {
        this.setData({
          operating: res.data
        })
      })
  },
  handleSearch() {
    get(`${APIS.vip}/search/order`, {
      search: this.data.search,
      shop: this.data.shopInfo.id
    })
      .then(res => {
        this.setData({
          orders: res.data
        })
      })
  }
})